<div class="login_div_user">
    <form action='<?php echo buildUrl('/user/passport/sublogin');?>' method="post" id='login_form'>
        <?php if($_GET["msg"]==1){?>
        <div><font style="color:red">账号或验证码错误</font></div>
        <?php }?>
        <div class='form-group'  >
            <input type="text" class="form-control" id='account' name='account' placeholder="手机号" value="" style='border-color:#8A8C76;background:rgba(0,0,0,0);color:white;' />
            <span id='check_mobile' style='color:red'> </span>
        </div>
        <div class='form-group' style="text-align: right">
            <input type="text" class="form-control" name="code" id='code' placeholder="验证码" value="" style='float:left;width:17rem;border-color:#8A8C76;background:rgba(0,0,0,0);color:white;' />
            <input type="button" id='subcode' class="form-control" onclick="_code();" style='float:right;border-color:#8A8C76;width:10rem;background:rgba(0,0,0,0);color:white;'  value="获取验证码"  >
            <br style='clear:both' >
            <div id='check_code' style='color:red;text-align:left;'> </div>
        </div>
        <div class="form-group login_sub" >
            <input type="button" class="btn btn-info form-control" onclick='_submit()' name="登录" value="登&nbsp;&nbsp;&nbsp;录" style='border-color:#8A8C76;background:rgba(0,0,0,0);color:white;'>
        </div>
        <input type="hidden" name='referer' value="<?php echo $_SERVER['HTTP_REFERER'];?>">
    </form>
    <div class="form-group login_sub" style="color:#999; margin:10rem  auto;" >唯美会互动科技（北京）有限公司</div>
</div>
<script type='text/javascript'>
    function _code() {
        var mobile = $("#account").val();
        var reg=/^(((1[1-9]{1}[0-9]{1})|(15[0-9]{1}))+\d{8})$/;
        if(mobile==''){
            $('#check_mobile').html('请输入手机号');
            return;
        }
        if(!reg.test(mobile)){
            $('#check_mobile').html('请正确输入手机号');
            return;
        }
        $.ajax({url: "/user/passport/code?store_id=<?php echo (int)$_GET['store_id'];?>&mobile=" + mobile, async: true, success: function (msg) {
                if (msg != 'true') {
                    alert(msg);
                    return false;
                }
                $("#subcode").val('60');
                $("#subcode").attr('disabled', 'disabled');
                var t = setInterval(function () {
                    var m = $("#subcode").val();
                    var str = parseInt(m) - 1;
                    if (str <= 0) {
                        str = '获取验证码';
                        $("#subcode").removeAttr('disabled');
                        clearInterval(t);
                    }
                    $("#subcode").val(str);
                }, 1000);
            }
        });
    }

    function _submit(){
        var mobile = $("#account").val();
        var code=$('#code').val();
        var reg=/^(((1[1-9]{1}[0-9]{1})|(15[0-9]{1}))+\d{8})$/;
        
        if(mobile=='' ){
            $('#check_mobile').html('请正确输入手机号');
            return;
        }
        if(!reg.test(mobile)){
            $('#check_mobile').html('请正确输入手机号');
            return;
        }
        if(code==''){
            $('#check_code').html('请输入验证码');
            return;
        }
        $('#login_form').submit();
    }
    
</script>

